package com.studentexam.student.service.impl;

import com.studentexam.student.dao.ExamQuestionMapper;
import com.studentexam.student.model.ExamQuestion;
import com.studentexam.student.service.ExamQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExamQuestionServiceImpl implements ExamQuestionService {

    @Autowired
    private ExamQuestionMapper examQuestionMapper;
//    @Autowired
//    private PersonMapper personMapper;
    @Override
    public int addExamQuestion(ExamQuestion examQuestion) {
        int returnInt=examQuestionMapper.insertExamQuestion(examQuestion);

        return returnInt;
    }

    @Override
    public int updateExamQuestion(ExamQuestion examQuestion) {
        int isUpdate=0;
        try{
            isUpdate=examQuestionMapper.updateExamQuestion(examQuestion);
        }catch (Exception e){
            isUpdate=-1;
            System.out.println("更新时执行sql报错原因为:"+e.getMessage());
        }
        return isUpdate;
    }

    @Override
    public int delExamQuestion(int examquestionid) {
        int returnDel=0;
//        try {
//            if (rolePersonPermissionMapper.getRoleCount(roleid) < 1) {
//                returnDel = roleMapper.delRole(roleid);
//            }
//        }catch (Exception e){
//            returnDel=-1;
//            System.out.println("删除失败原因为："+e.getMessage());
//        }
        return returnDel;
    }

    @Override
    public List<ExamQuestion> getByExamQuestionid(int examquestionid) {
        List<ExamQuestion> examQuestionList=examQuestionMapper.getByExamQuestionid(examquestionid);
        return examQuestionList;
    }

    @Override
    public List<ExamQuestion> getAllExamQuestion(ExamQuestion examQuestion){
        List<ExamQuestion> examQuestionList = examQuestionMapper.getAllExamQuestion(examQuestion);
        return examQuestionList;
    }
}
